import {createRouter, createWebHistory} from 'vue-router'
import Login from '@/views/Login/index'
import Layout from '@/views/Layout/index'
import Home from '@/views/Home/index.vue'
import Manage from '@/components/Manage.vue'
import LayoutMain from '@/components/LayoutMain.vue'
import Personal from '@/components/Personal.vue'
import Description from '@/components/Description.vue'
import Favorites from '@/components/Favorites.vue'
import MyArticle from '@/components/MyArticle.vue'
import ArticleDetails from '@/components/ArticleDetails.vue'
import Register from '@/views/Register.vue'
import UserManage from '@/components/ManageSon/UserManage.vue'
import ArticleManage from '@/components/ManageSon/ArticleManage.vue';
import Auth from '@/components/ManageSon/Auth.vue';
import SearchArticle from '@/components/SearchArticle';
import {useUserStore} from "@/store/user";

const routes = [
    {
        path: '',
        component: Layout,
        children: [
            {
                path: '',
                component: Home,
                children: [
                    {
                        path: '',
                        component: LayoutMain
                    },
                    {
                        path: '/manage',
                        component: Manage,
                        children: [
                            {
                                path: '',
                                component: ArticleManage
                            },
                            {
                                path: 'userManage',
                                component: UserManage
                            }, {
                                path: 'adminManage',
                                component: Auth
                            }
                        ]
                    }, {
                        path: '/detail',
                        component: ArticleDetails
                    },
                    {
                        path:'/search',
                        name:"Search",
                        component: SearchArticle,
                        props:true

                    },
                    {
                        path: '/personal',
                        component: Personal,
                        children: [
                            {
                                path: '',
                                component: Description
                            }, {
                                path: 'favorites',
                                component: Favorites
                            }, {
                                path: 'My',
                                component: MyArticle
                            }
                        ]
                    },
                ]
            },
        ]
    },
    {
        path: '/login',
        component: Login
    }, {
        path: '/register',
        component: Register
    }
]

const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})
export default router
